﻿<%@ Page Title="Quản lý tài khoản người dùng" MasterPageFile="~/Admin/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="QLTaiKhoanNguoiDung.aspx.cs" Inherits="Transport.Admin.QLTaiKhoanNguoiDung" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <p>
        <b>Tên đăng nhập:</b>
        <asp:TextBox ID="txt_Username" runat="server" />
        <b>Họ tên:</b>
        <asp:TextBox ID="txt_Name" runat="server" />
        <asp:Button ID="btnDisplayUsernames" runat="server" Text="Tìm" />
    </p>
    <p>
    <b>Loại người dùng:</b>
    <asp:DropDownList ID="ddl_User" runat="server" 
            DataSourceID="EntityDataSource_LND" DataTextField="ten_loai" 
            DataValueField="ma_loai" AutoPostBack="True" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
        <asp:EntityDataSource ID="EntityDataSource_LND" runat="server" 
            ConnectionString="name=transportEntities" 
            DefaultContainerName="transportEntities" EnableFlattening="False" 
            EntitySetName="loai_nguoi_dung" EntityTypeFilter="loai_nguoi_dung">
        </asp:EntityDataSource>
    </p>
    <div style="zoom: 1; overflow: auto;">
    <asp:GridView ID="GridView_User" runat="server" AllowPaging="True" 
        CellPadding="4" DataSourceID="EntityDataSource_NguoiDung" ForeColor="#333333" CellSpacing="4"
        GridLines="None" AutoGenerateColumns="False" DataKeyNames="ten_dang_nhap">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:BoundField DataField="ten_dang_nhap" HeaderText="Tên đăng nhập" 
                ReadOnly="True" SortExpression="ten_dang_nhap" />
            <asp:TemplateField HeaderText="Loại người dùng">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uLND" runat="server" 
                        DataSourceID="EntityDataSource_LND" DataTextField="ten_loai" 
                        DataValueField="ma_loai" SelectedValue='<%# Bind("loai_nguoi_dung") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uLND1" runat="server" 
                        DataSourceID="EntityDataSource_LND" DataTextField="ten_loai" 
                        DataValueField="ma_loai" SelectedValue='<%# Bind("loai_nguoi_dung") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="password" HeaderText="Password" 
                SortExpression="password" />
            <asp:BoundField DataField="ho_ten" HeaderText="Họ tên" 
                SortExpression="ho_ten" />
            <asp:BoundField DataField="nam_sinh" HeaderText="Năm sinh" DataFormatString="{0:d}" ApplyFormatInEditMode="true"
                SortExpression="nam_sinh" />
            <asp:BoundField DataField="dia_chi" HeaderText="Địa chỉ" 
                SortExpression="dia_chi" />
            <asp:BoundField DataField="sdt" HeaderText="Điện thoại" SortExpression="sdt" />
            <asp:BoundField DataField="chuc_danh" HeaderText="Chức danh" 
                SortExpression="chuc_danh" />
            <asp:BoundField DataField="cong_ty" HeaderText="Công ty" 
                SortExpression="cong_ty" />
            <asp:BoundField DataField="fax" HeaderText="Fax" SortExpression="fax" />
            <asp:BoundField DataField="cmnd" HeaderText="Số CMND" SortExpression="cmnd" />
            <asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" />
        </Columns>
        <FooterStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        <SortedAscendingCellStyle BackColor="#FDF5AC" />
        <SortedAscendingHeaderStyle BackColor="#4D0000" />
        <SortedDescendingCellStyle BackColor="#FCF6C0" />
        <SortedDescendingHeaderStyle BackColor="#820000" />
    </asp:GridView>
    <asp:EntityDataSource ID="EntityDataSource_NguoiDung" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" 
        EnableFlattening="False" 
        EntitySetName="nguoi_dung" EntityTypeFilter="nguoi_dung"
        EnableDelete="True" EnableInsert="True" EnableUpdate="True"
        Where="it.loai_nguoi_dung = CASE WHEN @UserType = '-1' THEN  it.loai_nguoi_dung ELSE @UserType END" >
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_User" Type="String"
                Name="UserType" PropertyName="SelectedValue"/>
        </WhereParameters>
    </asp:EntityDataSource>
    <asp:QueryExtender ID="qeSearch" runat="server" TargetControlID="EntityDataSource_NguoiDung">
        <asp:SearchExpression DataFields="ten_dang_nhap" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_Username" />
        </asp:SearchExpression>
        <asp:SearchExpression DataFields="ho_ten" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_Name" />
        </asp:SearchExpression>
        <asp:OrderByExpression DataField="ten_dang_nhap" Direction="Ascending" />
    </asp:QueryExtender>
    </div>
</asp:Content>